package org.fuys.etp.core.metrics.impl.trend.type;

import org.fuys.etp.core.model.type.EtpTaskTrendTypeEnum;
import org.fuys.etp.core.model.vo.TpConfigVO;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @projectName: fuys-etp-final
 * @package: org.fuys.etp.core.metrics.impl.trend.type
 * @className: StageJudgeTypeProcessor
 * @author: WangJing
 * @description: TODO
 * @date: 2025/2/19 10:26
 * @version: 1.0
 */
public interface StageJudgeTypeProcessor {

    /** 阈值判断
     * @param expansion 是否是验证扩容
     * @param compareType 阈值数值比较类型
     * @param poolExecutor 线程池
     * @param configVO 配置
     * @return 趋势
     */
    public Integer judge(boolean expansion, String compareType, ThreadPoolExecutor poolExecutor, TpConfigVO configVO);

    default Integer compare(String compareType,double target,double value,boolean expansion){
        boolean result = false;
        switch (compareType){
            case "EQ":
                result = target == value;
                break;
            case "GT":
                result = value > target;
                break;
            case "LT":
                result = value < target;
                break;
            case "GE":
                result = value >= target;
                break;
            case "LE":
                result = value <= target;
                break;
        }
        if(expansion && result){
            return EtpTaskTrendTypeEnum.INCREASE.getType();
        }else if(!expansion && result){
            return EtpTaskTrendTypeEnum.DECREASE.getType();
        }else{
            return EtpTaskTrendTypeEnum.NONE.getType();
        }
    }

}
